package cn.edu.bzu.ie.sf.mealsmisweb.service.impl;

import cn.edu.bzu.ie.sf.mealsmisweb.entity.Department;
import cn.edu.bzu.ie.sf.mealsmisweb.mapper.DepartmentMapper;
import cn.edu.bzu.ie.sf.mealsmisweb.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @version v1.0.0
 * @Package : cn.edu.bzu.ie.sf.mealsmisweb.service.impl
 * @Description : 部门信息业务实现类
 * @Create on : 2021/8/10 10:41
 * @author: Feng Song 宋锋
 **/
@Repository
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    /**
     * 获取所有的部门信息-支队管理、用户注册、用户添加时的查询
     * @return List<Department> 实例
     */
    public List<Department> getAllDepartmentList(){
        return departmentMapper.getAllDepartmentList();
    }

    /**
     * 获取某个部门下的所有部门信息-用于大队用户查看管理本部门下的部门信息
     * @param pid 父部门的id
     * @return List<Department> 实例
     */
    public List<Department> getAllDepartmentListByPid(int pid){
        return departmentMapper.getAllDepartmentListByPid(pid);
    }

    /**
     * 获取所有的你级部门，deptype=0或1，用于部门管理中部门添加、修改
     * @return List<Department> 实例
     */
    public List<Department> getAllParentDepartmentList(){
        return departmentMapper.getAllParentDepartmentList();
    }

    /**
     * 获取某个部门信息
     * @param id 部门的id
     * @return Department 实例
     */
    public Department getDepartmentById(int id){
        return departmentMapper.getDepartmentById(id);
    }

    /**
     * 添加部门信息
     * @param item 要添加的部门信息
     * @return int 影响的行数
     */
    public int addDepartment(Department item){
        return departmentMapper.addDepartment(item);
    }

    /**
     * 修改部门信息
     * @param item 要修改的部门信息
     * @return int 影响的行数
     */
    public int editDepartment(Department item){
        return departmentMapper.editDepartment(item);
    }

    /**
     * 删除部门信息
     * @param id 要删除部门的id
     * @return int 影响的行数
     */
    public int delDepartment(int id){
        return departmentMapper.delDepartment(id);
    }
}
